package com.jwgf.smarowindingmachine_unity.ui;

import java.util.Locale;

import com.jwgf.smarowindingmachine_unity.R;

import android.app.AlertDialog;
import android.app.Dialog;
import android.app.DialogFragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.webkit.WebSettings;
import android.webkit.WebView;


public class HelpDialog extends DialogFragment {

	private WebView wv;

	@Override
	public void onResume() {
		super.onResume();
		getDialog().getWindow().setLayout(800, 600);
	}

	// @SuppressLint("InflateParams")
	@Override
	public Dialog onCreateDialog(Bundle savedInstanceState) {
		AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
		LayoutInflater inflater = getActivity().getLayoutInflater();
		View v = inflater.inflate(R.layout.fragment_help, null);
		wv = (WebView) v.findViewById(R.id.help);
		wv.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);
		wv.getSettings().setLoadWithOverviewMode(true);
		
		String language = Locale.getDefault().getLanguage();
		if (language.equals("zh")) 
		{
		wv.loadUrl("file:///android_asset/help/index.html");
	
		builder.setView(v).setPositiveButton("关闭", null);
		}
		else
		{
		wv.loadUrl("file:///android_asset/help-en/index.html");
		builder.setView(v).setPositiveButton("close", null);
		}
	
		
		return builder.create();
	}

}
